<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Users extends CI_Controller {
    
    function Users()
    {
        parent::__construct();
    }
    
    function index()
    {
        // Check if the user is logged in
        if(! $this->session->userdata('user_id'))
        {
            // If not, redirect to the login page
            redirect(base_url() . 'login/');
        }
        
        redirect(base_url() . 'books/');
    }
    
    function login()
    {
        // Check if the user is logged in
        if($this->session->userdata('user_id'))
        {
            // If not, redirect to the login page
            redirect(base_url());
        }
        
        $data['title']      = 'Login';
        $data['js']         = array('users_js');
        $data['js_func']    = array('login');
        
        $this->load->view('header_view', $data);
        
        $this->load->view('login_view');
        
        $this->load->view('footer_view');
    }
    
    function logout()
    {
        if($this->session->userdata('user_id'))
        {
            $this->session->unset_userdata('user_id');
        }
        
        redirect(base_url() . 'login/');
    }
    
}

/* End of file users.php */
/* Location: ./application/controllers/users.php */